import os

from django.conf import settings


def convert_address(path):
    print(f"ENVIRONMENT: {settings.ENVIRONMENT}")

    # 判断环境
    if settings.ENVIRONMENT == "production":
        if path.startswith('/'):
            path = path[1:]  # 去掉前导斜杠
        return os.path.join(settings.BASE_DIR, path)
    else:
        if path.startswith('/'):
            path = path[1:]
        normalized_file_path = path.replace('/', os.sep)
        final_path = os.path.join(settings.BASE_DIR, normalized_file_path)

        return final_path
